Skip to content

feat(knowledge): knowledge-pgvector, an open vector store on PostgreSQL, and the index fingerprint (#37100) - #37337

Merged
os-zhuang merged 12 commits into
mainfrom
claude/project-thread-vcp8s3
Nov 25, 2026
Merged

os-zhuang merged 12 commits into
mainfrom
claude/project-thread-vcp8s3

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #37100

Clause-②: yes
Metadata-protocol: none

维护者速读

  • 自建部署的知识库可以直接用自己的 PostgreSQL(装 pgvector 扩展)存向量做检索,不再需要另外的向量服务;换了嵌入模型或切分方式后,旧索引会被明确拒绝并提示重建,而不是悄悄返回混杂的结果。
  • 属于「知识检索」专题,补上开源向量库这一块,并为后续的新代际重建和其他存储打好统一的指纹规则。
  • 数据库没装扩展或没权限时,系统照常启动,知识源返回「暂不可用」;要执行的 SQL 和数据库报错只给运维看(健康检查、启动日志),不会出现在用户的检索回答里。新包默认不启用,撤回只需不注册该插件。
  • 本 PR 改了 CI 工作流文件,需要你批准。新加的两步 CI 只在完整跑批和合并队列里运行(队列里不卡合并),席位无权在分支上手动触发;本地已用 CI 同一镜像(pgvector 0.8.7)跑通。如需在 CI 里看到绿灯,可在分支上手动触发一次 ci.yml。

What changes

New package @objectstack/knowledge-pgvector (Apache-2.0) — KnowledgePgvectorPlugin registers PgvectorKnowledgeAdapter (id pgvector).

  • Storage in its own schema os_knowledge (option schema): knowledge_generation (source_id, generation, fingerprint, recipe_hash, dim, model, state, created_at) and one passage table per width, knowledge_vec_dWIDTH (source_id, generation, chunk_id, document_id, source_record_id, organization_id, content, title, heading_path, doc_hash, chunk_hash, metadata jsonb, embedding vector(WIDTH)). Object tables live in the connection's current_schema(), and the driver's introspection / os migrate plan read only that schema, so these tables can neither collide with an object table nor be reported as drift.
  • Database: the url option, else OS_DATABASE_URL / legacy DATABASE_URL when it is postgres://; its own pg.Pool (poolMax, default 4; connectTimeoutMs, default 5000, so an unreachable host does not hold boot). Every embed runs before a connection is checked out for the write. The kernel's embedder is read at each call, never cached. Two deployments sharing one database set their own schema (README). With per-organization databases the store is still the one database the plugin connects to; isolation is the organization_id column, filtered in SQL.
  • Not ready (no vector extension and no right to create it, or no right to create the schema): nothing is created past the failing step, the plugin still registers, boot continues, healthCheck answers ok: false and the boot warning carries the SQL, every call answers 503 SERVICE_UNAVAILABLE; the next call retries (no restart). An unreachable database is diagnosed as unreachable, with no SQL.
  • What a caller reads: every refusal's message is one sentence (no driver text, SQL or schema name). Operator text travels in the error's remedy, shown by healthCheck, the boot warning, a reindex result and the service's warn log — never in refused[].message or a thrown search refusal. The contract TSDoc of beginBuild states this convention.
  • Search: the embedder is resolved before the fingerprint is compared (no embedder ⇒ 503, never a 409 on a healthy index); exact cosine scan via the extension's own schema-qualified cosine-distance operator and vector type (no HNSW, so 3072 dims work); organization filter and metadata-equality filter in the same WHERE, before ORDER BY distance LIMIT topK; a passage with cosine similarity not above 0 is not a hit. Hits carry the stored docHash (K8 item 3, read by service-knowledge: search returns records, not chunks — granularity and groupBy #37103's record-level freshness check) and the passage's headingPath (item 14). queryPrefix option is prepended to queries only.
  • Writes: takes the service's chunks (capabilities.chunks); chunk_hash per passage; an unchanged passage is not re-embedded (row metadata rewritten, the UPDATE checked for its row: one removed by a concurrent write makes the batch plan again, so the passage is embedded, not lost); stale chunks of a document deleted in the same transaction.
  • listDocuments on the write-target generation, byte order (COLLATE "C") for both the order and the cursor.
  • Fingerprint: a write or search under another fingerprint, or with an embedder of another width, is refused 409 KNOWLEDGE_REBUILD_REQUIRED; beginBuild under the stored fingerprint is a no-op, under another it is refused and its remedy (the convention is stated once on IKnowledgeAdapter) (carried into the reindex result) is the exact statements that clear the source: one DELETE per existing passage table, then the generation row (second-generation builds are knowledge-pgvector: a changed fingerprint builds a new generation and switches to it #37101). A first generation never adopts leftovers: opening it deletes the source's passage rows left without a generation row, in the same transaction, only by the call whose insert opened it; completeBuild records the recipe hash; indexStatus reads both back.
  • README: options, database/schema, setup SQL, HNSW as an operator step with the 2,000-dimension limit, rebuilds, and that stored text is as sensitive as the record and is in backups.

K8 item 8 (ADR-0161 K7), whole, as the Execution note asks

  • @objectstack/service-knowledge: computeIndexFingerprint (model, variant, dimensions from the adapter's embedding descriptor; resolved split + SPLIT_ALGORITHM_VERSION; content recipe + ASSEMBLY_RULE_VERSION) and computeRecipeHash (where, metadataFields, title field + TITLE_RULE_VERSION, withheld fields), SHA-256 over sorted-key JSON, pinned by index-fingerprint.test.ts. Every adapter call carries them (AdapterContext.index, AdapterSearchOptions.index). indexExpectation is exported. A complete reindex calls beginBuild before listing or writing (refusal ⇒ ok: false, nothing written, the adapter's remedy in the message) and completeBuild after the purge (a throw ⇒ ok: false); a capped or dry-run walk calls neither. The repair of a stale record (service-knowledge: search returns records, not chunks — granularity and groupBy #37103's repairStale) goes through the event-sync path, whose upsert/delete carry index. The chunk-target setting is read once per search.
  • @objectstack/spec/contracts: AdapterEmbeddingDescriptor.model/dimensions/variant, AdapterIndexExpectation, AdapterIndexStatus, IKnowledgeAdapter.indexStatus?/beginBuild?/completeBuild?, IEmbedder.model?. All optional.
  • Coded refusal through search (card comment, K7 rule 5): KnowledgeService.search keeps its signature (K9 rule 3); a source refused with a coded error (SCREAMING code + 4xx/5xx status) is dropped from the answer and logged by name; when no source answers, the refusal is thrown with its code/status and refused naming each source. A source that answers the first round and refuses the refill is refused for the whole search (its first-round hits dropped), so no source is both answered and named as refused. KnowledgeService.searchWithRefusals returns { hits, refused }; search_knowledge adds refused (sources the caller can see only) when non-empty.
  • knowledge-memory is the reference: active + under-construction generations, switch at completeBuild, all flags true in its contract run.
  • embedder-openai: model is public and reported.
  • Contract suite: implements gains indexStatus, builds, refusesOtherFingerprint, generations with 9 cases (carry, fingerprint vs recipe-hash variation, build pair, status, search refusal, write refusal, through-service named/whole refusal, generation switch, rebuild after recipe change).
  • KNOWLEDGE_REBUILD_REQUIRED registered in the error-code ledger under service-knowledge (the suite asserts it), knowledge-memory and knowledge-pgvector; generated references regenerated.

CI (Tier H — .github/workflows/ci.yml): Temporal Conformance never runs on pull_request; it runs on the full battery and, for an entry whose diff hits the temporal_live paths (this one does), in the merge queue, where it is advisory, not a required check. No existing step of Temporal Conformance (live PG + MySQL) runs this package, so two steps are added after the runtime leg (build @objectstack/knowledge-pgvector..., then vitest run live-postgres with OS_TEST_POSTGRES_URL and OS_EXPECT_LIVE_DIALECT_MATRIX=1, so a missing server is red, never a skip); service-knowledge/src/testing.ts joins the temporal_live merge-queue paths; the build-step count comment says five. The job's image is already pgvector's (#37095).

Why

Card #37100 (ADR-0161 Execution row 8a): the open, self-hosted vector store, and the fingerprint that keeps two models' vectors from ever being ranked against each other.

Open question

searchWithRefusals is a class method of KnowledgeService, not a member of IKnowledgeService (K9 rule 3 keeps search's signature and return type). search_knowledge reads it structurally. Options: (A) keep it on the class (this PR); (B) add an optional IKnowledgeService.searchWithRefusals? member in a follow-up with its own K9 dated note. Recommendation A until a second consumer needs it.

Deviations from the card

Tests

At head 065c98ff (main merged at 83fef223, after #37335 landed as 38017753):

  • @objectstack/knowledge-pgvector, live, against the CI job's own image (mirror.gcr.io/pgvector/pgvector:0.8.7-pg16@sha256:484e8380…, run locally in Docker), the CI step's exact command (pnpm --filter @objectstack/knowledge-pgvector exec vitest run live-postgres, OS_EXPECT_LIVE_DIALECT_MATRIX=1): Test Files 3 passed (3), Tests 47 passed (47) (contract suite 34, acceptance 11, real-driver reindex 2). The whole package against PostgreSQL 16 + pgvector 0.6: Test Files 4 passed (4), Tests 57 passed (57) (the above plus 10 unit cases; one of them now also pins listDocuments answering 503 with no embedder).
  • @objectstack/service-knowledge: Test Files 12 passed (12), Tests 315 passed (315) (one case pins that a refusal's remedy reaches the warn log and never refused[].message or the thrown message). @objectstack/knowledge-memory: 46 passed. @objectstack/embedder-openai: 31 passed. typecheck (source and tests) green for all four; eslint clean.
Ablations of the review fixes (one-shot, each restored; each fails exactly one case)
  • fingerprint compared before the embedder is resolved: the not-ready "no embedder ⇒ 503" case fails.
  • leftover passage rows not deleted when a first generation opens: the acceptance "never adopts passages left behind" case fails (the passage is not re-embedded).
  • the unchanged-passage UPDATE not checked for its row: the acceptance concurrent-write case fails (the passage is lost).
  • a refused beginBuild ignored by the service: the service stub "stops before any listing or write" case fails.
  • a throwing completeBuild swallowed: the service stub ok: false case fails.
  • the kernel embedder cached by the plugin: the plugin "re-registered embedder is reported at once" case fails.
  • (round 2) listDocuments compares before resolving the embedder: the not-ready no-embedder case fails; the service hands the remedy to the caller: the remedy-boundary case fails.

Earlier ablations (organization filter, chunk-hash skip, search fingerprint check) and the docHash/headingPath ablation (3 suite cases fail) are unchanged.

Local derived gates (dispatch-gates --commands, 167 commands)

At 7027f457: 166 exit 0 (the round-2 delta at 065c98ff re-ran typecheck, eslint, api-surface, spec docs, engine-double, tenant-audit and system-context censuses: all green). One NOT MEASURED (exit 3, a prerequisite refusal left to CI): check-plugin-teardown-shape --self-test (needs a full clone). The push hook's commit-trailer check is green (the two new commits carry the model-free trailer pair).

Acceptance notes

Acceptance Where
3072-dim works acceptance.live-postgres.test.ts — stores and ranks 3072-wide vectors (column type read back as vector(3072))
two orgs never see each other's hits (adapter + service) adapter: acceptance… two organizations case; service: contract suite organization cases under isolated / group
missing extension → readable error with SQL, boot continues not-ready.test.ts (adapter refusal text, healthCheck false, plugin start resolves and warns, recovery after the SQL runs)
same content re-indexed → no embed call acceptance… unchanged passage case (adapter) and second complete reindex case (service)
changed fingerprint → rebuild-needed error, old rows not served contract suite search/write refusal cases; acceptance… changed embedding model case through the service; acceptance… printed statements run as printed, and a first generation that never adopts rows left behind (L1 must-fix 2)
contract suite passes in CI on real PG contract.live-postgres.test.ts in the new Temporal Conformance step
reindex over a real driver, mixed-case and numeric-looking ids (comment 7145881825) reindex-real-driver.live-postgres.test.ts — 227 records over 3 walk pages, each indexed once, second reindex writes and embeds nothing

Verification

Two-minute check: OS_TEST_POSTGRES_URL=postgres://… pnpm --filter @objectstack/knowledge-pgvector exec vitest run against any PostgreSQL with pgvector available — expect Test Files 4 passed, Tests 57 passed.

CI evidence for the two new live steps: the relay lets a seat dispatch no ci.yml run, so the reading above (the CI image by digest, the step's exact command) stands in for it. A maintainer who wants it in CI can run ci.yml by workflow_dispatch on this branch; the job is advisory in the merge queue either way.

Read first: packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts (upsert, search, ready), packages/services/service-knowledge/src/knowledge-service.ts (walk build calls, searchWithRefusals), .github/workflows/ci.yml (the two new steps).

Overlap: #37335 (#37103) landed first; main is merged here (83fef223), keeping both intents in knowledge-service.ts (record-level answers and freshness repair from main, the refusal report from here), testing.ts and knowledge-memory/src/index.ts.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

Generated by Claude Code

@github-actions github-actions Bot added size/xl ci/cd dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 5 package(s): @objectstack/embedder-openai, @objectstack/knowledge-memory, @objectstack/knowledge-pgvector, @objectstack/service-knowledge, @objectstack/spec, touching 140 documentable anchor(s). ⚠️ 10 changed file(s) yielded no anchor (packages/plugins/knowledge-pgvector/LICENSE, packages/plugins/knowledge-pgvector/README.md, packages/plugins/knowledge-pgvector/package.json, …), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

31 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 7f62348dfa501bb41c67c20617a0b3bb5ed9931b.

⛔ 10 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 10 changed file(s) yielded no anchor (packages/plugins/knowledge-pgvector/LICENSE, packages/plugins/knowledge-pgvector/README.md, packages/plugins/knowledge-pgvector/package.json, …) — pages documenting those are invisible to this run
  • 42 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 176 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 7f62348dfa501bb41c67c20617a0b3bb5ed9931b → packageMentionDocs.

Which tree this was computed on

This run read content/docs from b14edb5aa095c01543b5b52dfd2a317adb16b76b — the merge of head 065c98ff72750a8bc8f2247bed8f91a1bbb116e3 into base 7f62348dfa501bb41c67c20617a0b3bb5ed9931b, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin b14edb5aa095c01543b5b52dfd2a317adb16b76b && git checkout b14edb5aa095c01543b5b52dfd2a317adb16b76b
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 7f62348dfa501bb41c67c20617a0b3bb5ed9931b 065c98ff72750a8bc8f2247bed8f91a1bbb116e3 && git checkout -B drift-repro 7f62348dfa501bb41c67c20617a0b3bb5ed9931b && git merge --no-ff 065c98ff72750a8bc8f2247bed8f91a1bbb116e3

node scripts/docs-audit/affected-docs.mjs --json 7f62348dfa501bb41c67c20617a0b3bb5ed9931b

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 7f62348dfa501bb41c67c20617a0b3bb5ed9931b → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U

维护者速读

  • 结论:这单先不合,退回补一轮。功能方向和接口都对(自建部署用自己的 PostgreSQL 做向量检索;换了嵌入模型或切分方式后旧索引被明确拒绝),对已有适配器(含 cloud 的 turso)没有破坏。
  • 要改的:两处会误导运维——嵌入服务没配好时,系统会把一个健康的索引报成「需要重建并删除」;提示的清理 SQL 不完整,照着只跑一半会让旧向量混进新索引。另外 feat(service-knowledge): search answers records, not passages — granularity, groupBy and a freshness check #37335 已先落地,本单要合并主干并补两项返回字段,否则真数据库上的用例会红。
  • 证据缺口:真数据库上的 41 个用例在 PR 上不跑,只在合并队列里跑,且红了也不拦;目前只有开发者本机一份结果,需要在分支上补一次完整 CI。
  • 需要你做的:现在不用。修完后再审一轮;届时因改了 CI 文件且超过 3000 行,仍需你批准。接口放置问题(searchWithRefusals)建议本单维持现状,是否进正式接口留给你定。

席位核对

REWORK — the contract members are the ones ADR-0161 K8 accepted and are additive-safe, but five items are open at this head: two defects in the store's refusal path, a merge of main that the store owes two hit keys to, one false changeset sentence, and no CI reading of the live suites. Nothing is armed; the PR stays draft.

Head-sha: 4ab06c2f0ab82479938696301e70d1ad0ef44435

Read whole: 45 files, +3495 / -94, nine commits on dbc1765a. Head re-read at the end of the review: unchanged.

形态

  • Open, draft, base main, first line Fixes #37100, the only closing keyword in the body. Body and changeset read Clause-②: yes · Metadata-protocol: none; all five packages patch, which is the level none takes. Skills-docs: not owed. l1-face.mjs --pr 37337: every mechanical item ok.
  • Governed, Tier H: check-governed-merges.mjs --pr 37337 reads 1 of 45 paths on the register (.github/workflows/ci.yml, Tier H by content: the new build step copies the job's four TURBO_* lines), and 3589 changed lines, over the 3000 line. Either alone makes it a human merge.
  • mergeable_state: dirty since feat(service-knowledge): search answers records, not passages — granularity, groupBy and a freshness check #37335 merged as 38017753. A test merge with origin/main at a182fbe3 conflicts in knowledge-service.ts, testing.ts and knowledge-memory/src/index.ts.
  • File surface against the claim: inside it, with three additions that a gate or the ledger forces and that are accepted below (error-code-ledger.zod.ts, content/docs/permissions/system-context.mdx row 46, the generated reference pages and spec baselines).

门禁 check-runs (at 4ab06c2f, read twice, last after the review)

  • 64 success, 11 skipped, 0 failed, 0 pending. Lint & Repo Gates: success. TypeScript Type Check: success. The 11 skips are the expected names.
  • Temporal Conformance (live PG + MySQL) is one of the skips: the job never runs on pull_request. The two steps this PR adds have not run in CI at any head.
  • Local at 4ab06c2f, scratch worktree, removed: service-knowledge 291/291 (12 files), knowledge-memory 43/43, embedder-openai 31/31, knowledge-pgvector 7 passed and 41 skipped without a URL; vitest run live-postgres selects the three live files (41 cases); with OS_EXPECT_LIVE_DIALECT_MATRIX=1 and no URL, 3 named failures. The 41 live cases: NOT MEASURED here (this container has PostgreSQL 16 without the vector extension).

逐项核对与消融 (12 single-change ablations, tree restored each time)

  1. Coded refusal collected in searchRound — off: 2 red in service-knowledge, 2 red in the memory contract run.
  2. beginBuild before a complete walk — off: 2 red (memory contract run). completeBuild after it — off: 3 red.
  3. The search carries index — off: 2 + 3 red. The whole refusal is thrown — off: 1 + 2 red.
  4. knowledge-memory refuses a search under another fingerprint — off: 4 red; a write — off: 1 red.
  5. search_knowledge adds refused — off: 1 red. The fingerprint covers variant — off: 2 red (the pinned digest and the five-component case).
  6. The not-ready refusal carries the SQL — off: 1 red (not-ready.test.ts).
  7. Two paths are not pinned by any suite that runs on a PR: a refused beginBuild answering ok: false (swallowed: all green; its one pin is a live case), and a completeBuild that throws (swallowed: all green; no pin at all).
  • Refusal cases assert code and status (the suite's expectRebuildRefusal, the tool cases, the not-ready cases).
  • The embedder-openai case cannot fail at run time without the change (the property existed, private); its pin is the type check.

完成标准对卡 (#37100, ten items, six acceptance lines)

  • Delivered as written: 1, 2 (with title, heading_path, recipe_hash beyond the list, stated), 3, 5, 7, 8, 10; K8 item 8 whole, as scope note 7145595033 asks; the reindex case over a real driver from 7145881825.
  • Item 4 and item 6 are delivered with the two defects in the fix list (items 1 and 2).
  • Item 9 and acceptance line 6 ("passes in CI on real PostgreSQL"): wired, not yet observed (item 5).

CI 改动 (.github/workflows/ci.yml, +32 / -2)

  • The claim's condition holds: on the base, the job's steps name driver-sql, the non-SQL backends, metadata-protocol and runtime; none runs this package, and Test Core runs it without a URL (a named skip).
  • Size: a build step and a run step shaped as the runtime leg above them, the step-count comment, and one temporal_live path. The secret references are the job's own four lines, copied. No smaller edit runs the suite; dropping the TURBO_* lines would not lower the tier, because the size line holds it at a human merge.
  • The one discretionary line is service-knowledge/src/testing.ts in temporal_live: every queue entry that touches the contract suite now starts the job (feat(service-knowledge): search inside chosen records — the record scope, by the records a source indexes or by a parent through a listed lookup #37342 does). Accepted: a change to the suite is a change to that step's verdict.
  • What the edit does not give: a required check. The job is advisory in the queue, so a red there lands and shows on main.

逐句核的散文面

  • Changeset: false — indexExpectation is listed among the new exports of @objectstack/service-knowledge and src/index.ts does not export it. Imprecise — "the platform's when OS_DATABASE_URL is PostgreSQL, else the url option": the code takes url first. The other sentences are true of the code.
  • README.md, protocol/knowledge.mdx 4.1, ai/knowledge-rag.mdx, the plugin's TSDoc: the same inverted precedence. knowledge-rag.mdx says the service "computes and checks" the fingerprint (the adapter checks). 4.1 says one generation row "per source and fingerprint" (the key is source and generation). The plugin option's TSDoc says the kernel embedder is "read at each call"; it is cached after the first read.
  • system-context.mdx row 46 and its census line: true. Generated reference pages and spec baselines: regenerated, gates green.

接受的偏差

范围外去向

落地条款

  • Clause-② declared and the path limb hit: the contract record below is FAIL at this head. No auto-merge is armed and no label is hung by this record.
  • After the fix list: a fresh record on the new head (the merge of main moves more than prose), every check green or an expected skip, a CI reading of the two new steps at that head, then pm:awaiting-merge and the maintainer's approval (Tier H).

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 4ab06c2f0ab82479938696301e70d1ad0ef44435
Local-runs: probe — four package suites, 12 ablations and two database-double probes in a scratch worktree, to learn which changes a test pins and to confirm two refusal paths; nothing was pushed, and the live PostgreSQL files could not be run here.
Scope: packages/spec/src/contracts/knowledge-adapter.ts, packages/spec/src/contracts/embedder.ts, packages/spec/src/api/error-code-ledger.zod.ts, .github/workflows/ci.yml + packages/services/service-knowledge/src/knowledge-service.ts, packages/services/service-knowledge/src/knowledge-index-fingerprint.ts, packages/services/service-knowledge/src/knowledge-tools.ts, packages/services/service-knowledge/src/testing.ts, packages/services/service-knowledge/src/split/splitter.ts, packages/plugins/knowledge-memory/src/index.ts, packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts, packages/plugins/knowledge-pgvector/src/plugin.ts, packages/plugins/knowledge-pgvector/src/sql.ts, packages/plugins/embedder-openai/src/index.ts
Security-touching: yes
Rule-change-verified: none

① Derived judgments

  • Every new member is in the K8 table in its decided shape. Item 8 a: AdapterContext.index? with fingerprint and recipeHash; AdapterSearchOptions.index? with fingerprint. Item 8 b: indexStatus?(ctx) answering fingerprint?, recipeHash?, building?. Item 8 c: beginBuild?(ctx) and completeBuild?(ctx). Item 7: IEmbedder.model?. Item 6: the descriptor's model?, dimensions?, variant?, which item 6 assigns to the PR that lands item 8. No member outside the table; item 13 and item 17 untouched.
  • AdapterIndexExpectation and AdapterIndexStatus are type names for those shapes, not members in K8's sense. KNOWLEDGE_REBUILD_REQUIRED is a ledger code for the refusal K7 rules 4 and 5 call for; the ADR fixes no name.
  • Rule 1 holds: each member lands with its reader (the service, knowledge-memory as reference, the store) and with suite cases; the Execution note ("item 8 lands whole, once") is met, including the pair case.
  • Rule 2 holds: every member is optional. An adapter without them is called as before, is handed index and may ignore it. Read in the tree and in objectstack-ai/cloud (code search plus the local checkout at d2c4981): KnowledgeRagflowAdapter, cloud's TursoKnowledgeAdapter and HashEmbedder implement none of the new members and compile unchanged; no cloud class holds a private model beside implements IEmbedder; nothing in cloud names searchWithRefusals, indexStatus or beginBuild.
  • One behaviour moves for every caller of KnowledgeService.search: a source whose adapter throws an error with a SCREAMING code and a 4xx/5xx status is no longer logged and read as empty; when no source answers, the call throws. K7 rule 5 asks for it and the changeset says it. knowledge-ragflow and the libSQL client throw no such shape; cloud's own search_knowledge handler catches and reports the message.

② Semver level

  • Clause-②: yes, Metadata-protocol: none, patch on all five packages: the level the kind takes (AGENTS.md, Post-Task Checklist step 3). No metadata key, accepted value or metadata type is added; the members are adapter-contract members, not authorable keys.
  • No narrowing: nothing published is removed or refused that was accepted. OpenAIEmbedder.model goes from private to public.
  • The changeset names an export that does not exist (indexExpectation): must-fix, below.

③ Boundary flags

  • Open question (4), searchWithRefusals on the class: K9 rule 3 is kept (search unchanged), and K7 rule 5 makes knowledge-pgvector: an open vector store on PostgreSQL — tables, exact search, listing, chunks #37100 the proposer. Recommendation: keep A in this PR. It adds nothing to IKnowledgeService, so no dated note is owed, and the one tool definition reads it. Its cost is a silent seam: a service that wraps or proxies IKnowledgeService loses the named refusals and falls back to hits alone (the whole refusal still throws, the partial one is only logged). B is the durable shape before cloud's in-app agent (row 13) or the first wrapper reads refusals; it is a member on a published contract and so the maintainer's decision, by a dated note. Escalated as a decision, not answered here.
  • Dev flag, the CI edit: answered in the seat section. Justified by the claim's condition; kept in this PR.
  • Dev flag, the overlap with feat(service-knowledge): search answers records, not passages — granularity, groupBy and a freshness check #37335: it merged first. See ④, must-fix 3.
  • SQL push-down: the organization filter, the metadata filter and the ranking are one statement; listing pages in SQL; the unchanged-passage read is one statement per batch. No id materialisation or in-app join where SQL could do it. Writes are one statement per passage inside one transaction: a cost, not a finding.
  • Security read: SQL construction (identifiers, values, the width-derived table name, filter keys), tenant isolation on every read path, the not-ready text and logs. No finding on injection or on the organization wall. Three findings on what refusal text carries and to whom, graded below without mechanism; specifics are in the seat reply.
  • Author: PR user.login is objectstack-fleet[bot].

④ Design judgment

packages/spec/src/contracts/knowledge-adapter.ts

packages/spec/src/contracts/embedder.ts

  • Holds: item 7 as decided, id stays a log label.

packages/spec/src/api/error-code-ledger.zod.ts

  • Holds: one code under the three packages that stamp or assert it; gates green.

.github/workflows/ci.yml

  • Holds as wiring (seat section). It gives an advisory reading, not a gate.

packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts

  • must-fix 1 — search compares the fingerprint before it resolves the embedder. With no embedder registered (the boot window, or the embedder unset in settings) a healthy index is refused 409 KNOWLEDGE_REBUILD_REQUIRED with the instruction to drop it, where upsert and beginBuild answer 503 SERVICE_UNAVAILABLE, no embedder. Confirmed with a database double. The wrong code, and a remedy that deletes a good index.
  • must-fix 2 — the clear-the-source remedy. The text is one runnable statement (the generation row) and a prose description of the second with a placeholder table name. A source whose generation row is gone while its passage rows remain is taken up by the next first generation under the same number; the complete reindex then lists those rows and skips every document whose hash is unchanged, so vectors of the old fingerprint are served under the new one (K7 rule 1, and the card's "old rows not served"). Owed: exact statements (the width is known), passages before the generation row, and a first generation that never adopts rows left under its number; a live case for it.
  • should-fix — an unreachable database is reported as "extension not installed" with the DDL, and the driver's own error text rides in the coded refusal to the caller.
  • should-fix — the search-path refusal hands operator text to the tool's caller; a caller needs the code and a sentence, the operator text belongs to the reindex result, the log and healthCheck.
  • should-fix — the unchanged-passage UPDATE is not checked for a row; under a concurrent rewrite of the same document a passage can go missing, and the document-hash skip then hides it.
  • nit — one identifier is quoted without doubling an embedded quote (a value a database owner sets).

packages/plugins/knowledge-pgvector/src/plugin.ts

packages/plugins/knowledge-pgvector/src/sql.ts

  • Holds: the schema is held to a lower-case identifier at construction, the width to a positive integer, every value is bound.

packages/services/service-knowledge/src/knowledge-service.ts

  • Holds against K7 rules 3 and 5: one plan per walk, the pair around a complete walk only, neither call under limit or dryRun, the refused sources named, the whole refusal only when none answers.
  • must-fix 3 — merge main (feat(service-knowledge): search answers records, not passages — granularity, groupBy and a freshness check #37335 is in). Both intents on search: the record-level answer and its freshness repair from main, the refusal report from this PR; every adapter call main added (the repair's upsert and delete) carries index. On main the suite asserts docHash on a hit under listDocuments and headingPath under chunks; the store declares both, so its hits must carry both (it already stores them), or the live contract run is red in a job that does not eject.
  • should-fix — two stub cases here: a refused beginBuild (ok: false, no listing, no write) and a completeBuild that throws (ok: false). Today neither is pinned on a PR.
  • nit — a source refused in the refill round is named in refused while its first-round hits stay in the answer.
  • nit — planIndex reads the chunk-target setting once per source per search.

packages/services/service-knowledge/src/knowledge-index-fingerprint.ts

  • Holds against K7: five components, values in sorted-key JSON, pinned digests, where and metadataFields left to the recipe hash (point 2). maxTokens rides in the resolved split: it is a value that cuts the text.

packages/services/service-knowledge/src/knowledge-tools.ts

  • Holds against K9 rules 1 to 3: one definition, refused limited to the sources the caller may see, search unchanged.

packages/services/service-knowledge/src/testing.ts, packages/plugins/knowledge-memory/src/index.ts, packages/services/service-knowledge/src/split/splitter.ts, packages/plugins/embedder-openai/src/index.ts

  • Hold. Nine new cases, each red under its ablation; the reference keeps an active generation and one under construction and switches at completeBuild.

Findings open at this head: five must-fix (three above; the false changeset export; the CI reading of the live suites at the landing head), eight should-fix (seven above; the inverted database precedence in the prose faces), six nits (four above; two prose sentences in the seat section).

Implemented-by: session_01JQwxbX5BF433x8ooJNQVRp
Reviewed-by: session_01JQwxbW5anP6GDaVi5LKi2U

VERDICT: FAIL

…pgvector hits carry docHash and headingPath

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbX5BF433x8ooJNQVRp
… exact clear-the-source SQL, no adoption of leftovers, operator text kept from callers

- search resolves the embedder before comparing fingerprints: no embedder is 503, never a 409 on a healthy index
- the clear-the-source remedy is exact statements (each passage table, then the generation row); a first generation deletes passage rows left behind as it opens
- refusal messages are one caller sentence; driver text and SQL travel in the error's remedy (healthCheck, boot warning, reindex result, log); an unreachable database is no longer reported as a missing extension
- an unchanged passage whose row a concurrent write removed is planned again, not lost
- the plugin reads the kernel embedder at each call and sets a connect timeout
- service: reindex results carry the remedy; a source refused in the refill round is dropped whole; the chunk target is read once per search; indexExpectation exported
- docs, README, changeset and contract TSDoc corrected (url precedence, generation key, shared-database schema)

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbX5BF433x8ooJNQVRp
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U

维护者速读

  • 结论:第二轮基本到位,还差一个小口子,再补一轮即可;目前不需要你动手。
  • 已修好的:上一轮两处会误导运维的问题都已修(嵌入服务没配好时检索不再误报「需要重建」;清理 SQL 现在完整可执行,只删一半也不会让旧向量混进新索引);已合并 feat(service-knowledge): search answers records, not passages — granularity, groupBy and a freshness check #37335 并补上两项返回字段;对外提示不再带数据库报错原文和 SQL。
  • 还差的:同一类误报在「非完整重建」的列举步骤上还留着一处(嵌入服务缺席时,运维看到的结果里仍会出现删除索引的 SQL),一行可修。另外 CI 在新提交上还在跑,尚无红。
  • 真数据库用例:这里仍无法亲测(没有带 pgvector 的数据库,也没有 Docker);开发者已用 CI 同一镜像跑出 47/47。席位无法触发那次 CI,批准前你可以在分支上手动跑一次 ci.yml;合并队列里那一步红了也不拦。

席位核对

REWORK — the round-1 fix list (PR comment 7172706810) is closed at this head except for one path of its first item, found on re-read; the checks at this head are still running. One small item, then a delta read.

Head-sha: 7027f4572d4534e19bd594ce1c04a7f2fed0e56d

Delta review: two commits on 4ab06c2f0ab82479938696301e70d1ad0ef44435 — 83fef223, the merge of origin/main at a182fbe3, and 7027f457, the fix list (12 files, +549 / -132). Both read whole; the rest of the PR stands as read in round 1. Head re-read at the end: unchanged.

形态

  • Open, draft, base main, first line Fixes #37100. Declarations unchanged: Clause-②: yes · Metadata-protocol: none, five packages patch.
  • Governed, Tier H, twice: 1 of 46 paths on the register (.github/workflows/ci.yml, untouched by the delta) and 4025 changed lines, over the 3000 line.
  • mergeable_state: blocked (draft), no longer dirty. main has moved to 49ad529d since the merge; no conflict reported.
  • The delta opens one new published surface: the option connectTimeoutMs on the new package, and the export indexExpectation the changeset already named. The spec delta is TSDoc only.

门禁 check-runs (at 7027f457, read twice)

  • 29 success, 11 skipped, 32 in progress, 0 failed (last read). Lint & Repo Gates: not measured (its jobs are still running). TypeScript Type Check: not measured. All-green: not measured.
  • Temporal Conformance (live PG + MySQL): skipped, as on every pull request.
  • Local at 7027f457, scratch worktree, removed: service-knowledge 314/314 (12 files), knowledge-memory 46/46, knowledge-pgvector 10 passed and 47 skipped without a URL. These match the dev's numbers. The 47 live cases: NOT MEASURED here again (no vector extension, no Docker daemon in this container).

逐项核对与消融 (6 single-change ablations at this head, tree restored each time)

  1. Must-fix 1, embedder before fingerprint — search resolves the embedder first. Compared first again: the new not-ready case red. Open on one path, see the fix list below.
  2. Must-fix 2, the clear-the-source remedy — the statements are exact (one DELETE per passage table found in the schema, then the generation row), and the transaction that opens a first generation deletes the source's leftover passage rows; only the call whose insert opened it clears. Read in the code and in the two live cases (the printed statements run as printed; a generation row deleted alone does not carry its vectors over). Not runnable here.
  3. Must-fix 3, the merge — every line of main that the head removes in the four overlapping files is one this PR replaces on purpose (listed and read). main's record-level answer, round cap, freshness repair and groupBy checks stand; the refusal report wraps them, and every return is hits plus refused. The store's hits carry docHash and headingPath from the stored columns. No adapter call is left without index: the repair goes through the event-sync write, which plans the index.
  4. Must-fix 4 — indexExpectation is exported; the sentence is true.
  5. Must-fix 5 — see the landing clause.
  6. Should-fix 6 and 7 — a failed first query is "cannot reach its database", with no SQL; a refused extension is the missing-extension case. A refusal's message is one sentence; driver text, schema name and SQL ride in remedy. The service names a refused source with the message alone and logs the remedy at warn; reindex results carry it. Driver text put back in the message: 2 red. The remedy handed to the caller by the service: green in every suite that runs on a pull request; its pin is a live case (the whole refusal through the service holds no DELETE).
  7. Should-fix 8 — both stub cases exist; a refused beginBuild swallowed: 1 red; a throwing completeBuild swallowed: 1 red.
  8. Should-fix 9 — the kernel embedder is read at each call; cached again: 1 red. Should-fix 10 — connectionTimeoutMillis from connectTimeoutMs, default 5000. Should-fix 13 — the in-place rewrite checks its row and the batch is planned again, three attempts; its pin is a live case.
  • Nits 14, 15, 17, 18, 19: done as described. Nit 16: a source that refuses the refill is refused for the whole search; no dedicated case, accepted.

逐句核的散文面 (delta sentences)

  • Changeset: the database precedence, connectTimeoutMs, "logs each refused one with the adapter's remedy", the refill sentence, "a caller is given the code and the adapter's one-sentence message, never its remedy" — each true of the code.
  • README.md: precedence, the timeout row, the shared-database paragraph, "one sentence; the SQL and the driver's text go only to the health check, the boot warning and the log", the unreachable sentence, the rebuild paragraph — true.
  • protocol/knowledge.mdx 4.1 and ai/knowledge-rag.mdx: precedence, "one row per source and generation", "computes and carries … the adapter checks", the not-ready and rebuild sentences — true.
  • PR body: test block pinned to 7027f457; it says the job never runs on a pull request and is advisory in the queue.

还开着的

  1. should-fix — the first item's defect class on its remaining path. With no embedder registered, listDocuments still compares the fingerprint and refuses a healthy index as one to rebuild, its remedy the clearing statements. It is reached by a reindex walk that is not a build (a limit; the listing runs before the first write), and the text lands in the operator's result. search, upsert and beginBuild answer no embedder. Confirmed with a database double. It also contradicts the sentence this delta added to the contract (an adapter that needs an embedder answers unavailable in that window rather than comparing). One guard and one unit case.
  2. nit — the service's side of should-fix 7 has no pin that runs on a pull request; a tool case with a refusal that carries remedy would give it one.
  3. nit — clearSql falls back to the generation-row statement alone when the table listing fails. Harmless now that a first generation clears leftovers.

接受的偏差 (round 1's stand; added this round)

范围外去向 (unchanged)

落地条款

  • Contract record below: FAIL at this head, on the one should-fix. Nothing is armed.
  • Must-fix 5, as far as a seat can take it: the relay dispatches no ci.yml, and the dev's reading is the job's own image by digest with the step's exact command, 47/47. That closes the version gap of round 1 (0.6 against 0.8.7). It is still one witness, and no CI run. It suffices for a Tier H handoff on these terms: the request for approval says the two steps have never run in CI and that the approver can dispatch ci.yml on the branch; the landing seat reads the queue entry's Temporal Conformance run, and a red there is a main-red for this lane.
  • After item 1: a delta read, every check at that head green or an expected skip, then pm:awaiting-merge.

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 7027f4572d4534e19bd594ce1c04a7f2fed0e56d
Local-runs: probe — three package suites, 6 ablations and one database-double probe in a scratch worktree, to confirm each round-1 fix is pinned and to test the remaining adapter calls with no embedder; nothing was pushed, and the live PostgreSQL files could not be run here.
Scope: packages/spec/src/contracts/knowledge-adapter.ts, packages/spec/src/contracts/embedder.ts, packages/spec/src/api/error-code-ledger.zod.ts, .github/workflows/ci.yml + packages/services/service-knowledge/src/knowledge-service.ts, packages/services/service-knowledge/src/knowledge-index-fingerprint.ts, packages/services/service-knowledge/src/knowledge-tools.ts, packages/services/service-knowledge/src/testing.ts, packages/services/service-knowledge/src/index.ts, packages/plugins/knowledge-memory/src/index.ts, packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts, packages/plugins/knowledge-pgvector/src/plugin.ts
Security-touching: yes
Rule-change-verified: none

① Derived judgments

  • Round 1 stands: every member is in the K8 table in its decided shape, each with its reader and its suite cases, all optional, additive-safe for knowledge-ragflow and for cloud's adapter and embedder. The delta adds no member, key or option to a published contract.
  • The spec delta is two TSDoc passages in knowledge-adapter.ts: the descriptor may be absent for a moment and an adapter that needs an embedder then answers unavailable; beginBuild separates an adapter that opens generations from one that refuses a new fingerprint, and states the remedy convention. The first is true of the store on three of four calls (④). The second is true of the code.
  • The merge keeps K8 items 3 and 14 as main landed them: the store returns docHash and headingPath as stored, which main's suite asserts under the flags the store declares.

② Semver level

  • Unchanged: Clause-②: yes, Metadata-protocol: none, patch on five packages. connectTimeoutMs is an option of a package this PR creates; indexExpectation is an added export. No narrowing.
  • A coded refusal's message loses its SQL and driver text and gains a remedy property: both are new in this PR, so no released behaviour moves.

③ Boundary flags

  • Dev flags and open_questions: the CI evidence is answered in the landing clause; the remedy convention is accepted as stated above; open question (4) stays escalated.
  • SQL push-down: unchanged. The delta adds one catalogue read per refusal and per first generation, and a bounded retry of a write; no id materialisation, no in-app join.
  • Security read of the delta: caller-facing text and operator text are now separate, and the identifier nit is closed. No new finding on injection or on the organization wall. One residual of round 1's first item, graded below; specifics in the seat reply.
  • Author: PR user.login is objectstack-fleet[bot].

④ Design judgment

packages/spec/src/contracts/knowledge-adapter.ts

  • Round-1 nit closed; the transient-descriptor sentence is the right rule for the next store.
  • nit — remedy is stated under beginBuild only, though the store sets it on every coded refusal; one home for the sentence would serve an adapter author better.

packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts

  • Round-1 must-fix 1 closed on search and pinned. should-fix — open on listDocuments, which still compares before it asks for an embedder (seat section, item 1).
  • Round-1 must-fix 2 closed: exact statements, passages first, and a first generation that clears what it finds. Two live cases.
  • Round-1 should-fix items closed: the unreachable diagnosis, one-sentence messages, the checked in-place rewrite with its retry. Round-1 nit closed (identifier quoting).
  • nit — the statement list falls back to the generation row alone when the table listing fails.

packages/plugins/knowledge-pgvector/src/plugin.ts

  • Round-1 should-fix items closed: the embedder is read at each call (pinned), the pool has a connection timeout, the README names the shared-database case.

packages/services/service-knowledge/src/knowledge-service.ts

  • Round-1 must-fix 3 closed: both intents on search, index on every adapter call, the repair included.
  • Round-1 should-fix closed: both stub cases, each red under its ablation.
  • The caller boundary holds: a refused source is named with the adapter's message, the remedy goes to the log and to reindex results. nit — pinned by a live case only.
  • Round-1 nits closed: the refill refusal, one settings read per search.

packages/services/service-knowledge/src/index.ts

  • Round-1 must-fix 4 closed.

packages/spec/src/contracts/embedder.ts, packages/spec/src/api/error-code-ledger.zod.ts, .github/workflows/ci.yml, packages/services/service-knowledge/src/knowledge-index-fingerprint.ts, packages/services/service-knowledge/src/knowledge-tools.ts, packages/services/service-knowledge/src/testing.ts, packages/plugins/knowledge-memory/src/index.ts

  • Untouched by the fix commit, or touched by the merge alone; hold as in round 1.

Findings open at this head: no must-fix in the code; one should-fix; three nits, accepted. The CI reading of the live steps is carried as a landing clause.

Implemented-by: session_01JQwxbX5BF433x8ooJNQVRp
Reviewed-by: session_01JQwxbW5anP6GDaVi5LKi2U

VERDICT: FAIL

…he remedy convention stated once

- listDocuments asks for the embedder before comparing fingerprints: no embedder is 503, never a 409 with clearing statements
- clearSql always includes the width the generation records, so a failed catalogue read never prints the generation row alone
- the contract states the coded-refusal remedy convention once, on IKnowledgeAdapter
- a service case pins that a remedy reaches the warn log and never refused[].message or the thrown message

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbX5BF433x8ooJNQVRp
@objectstack-fleet

objectstack-fleet Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U

维护者速读

  • 结论:可以交你批准。自建部署可以直接用自己的 PostgreSQL(装 pgvector 扩展)做知识库向量检索;换了嵌入模型或切分方式后,旧索引被明确拒绝并提示重建,不会悄悄返回混杂结果。
  • 三轮审核提出的问题已全部修完并有测试钉住;对已有适配器(含 cloud 的 turso)没有破坏;新包默认不启用,撤回只需不注册该插件。
  • 要知道的一处证据缺口:真数据库上的两个 CI 步骤从未在 CI 里跑过(PR 上不跑;合并队列里跑,但红了也不拦)。目前的依据是开发者用 CI 同一镜像本机跑出的 47/47;批准前你可以在分支上手动跑一次 ci.yml。
  • 需要你做的:等本提交的检查全部跑完为绿后批准(改了 CI 文件且超过 3000 行,必须人工批准);接口放置问题(searchWithRefusals 是否进正式接口)另行请你定夺,本单维持现状。

席位核对

ACCEPT — the one item of the round-2 record (PR comment 7174494844) is closed at this head and pinned, its three nits with it, and nothing else moved. Landing waits for the checks still running and for the Tier H approval, on the terms in the landing clause.

Head-sha: 065c98ff72750a8bc8f2247bed8f91a1bbb116e3

Delta review: one commit on 7027f4572d4534e19bd594ce1c04a7f2fed0e56d, 4 files, +74 / -15. Read whole against that head; the rest of the PR stands as read in rounds 1 and 2. Head re-read at the end: unchanged.

形态

  • Open, draft, base main, first line Fixes #37100, the only closing keyword in the body. Clause-②: yes · Metadata-protocol: none, five packages patch. l1-face.mjs --pr 37337: every mechanical item ok; the floor checks and all-checks are not yet measured.
  • Governed, Tier H, twice: .github/workflows/ci.yml on the register (untouched since round 1), and 4084 changed lines, over the 3000 line.
  • mergeable_state: blocked (draft); no conflict with main.
  • The delta opens no new scope: two source files of the store and the spec's TSDoc, two test files. No published member, option or export moves.

门禁 check-runs (at 065c98ff, read after the push)

  • 18 success, 11 skipped, 22 in progress, 0 failed (last read). One PR-body guards run reads cancelled; a later run of the same name on this head is success (the body was edited), so it is not a red. Lint & Repo Gates: not measured (its jobs are still running). TypeScript Type Check: not measured. All-green: not measured.
  • Temporal Conformance (live PG + MySQL): skipped, as on every pull request.
  • Local at 065c98ff, scratch worktree, removed: service-knowledge 315/315 (12 files), knowledge-memory 46/46, knowledge-pgvector 10 passed and 47 skipped without a URL. The 47 live cases: NOT MEASURED here in any round (no vector extension, no Docker daemon in this container).

逐项核对与消融 (2 single-change ablations at this head, tree restored)

  1. The listing and the embedder — listDocuments resolves the embedder before it reads the write target and hands it in, so with none registered it answers 503 SERVICE_UNAVAILABLE, as search, upsert and beginBuild do. The not-ready case now covers a search and a listing. Compared first again: that case red.
  2. The caller boundary on a pull request — a new service case over two stub sources, one refusing with a remedy: the refused source is named with its message alone, the warn log holds the remedy, and the thrown whole refusal and its refused list hold none. The remedy handed to the caller: that case red.
  3. The statement list — it always names the width the source's generation records, joined with the tables found in the schema, so a failed catalogue read no longer leaves the generation row alone. Read in the code; its callers each pass the generation's width.
  4. The remedy convention — stated once on IKnowledgeAdapter ("any member may refuse … its message is one sentence … operator text goes in remedy"); beginBuild points to it. True of the store and of the service.
  • Nothing else moved: the four files above are the whole delta.

逐句核的散文面 (delta sentences)

  • knowledge-adapter.ts TSDoc, the new section: each sentence true of the code — both codes and statuses, the one-sentence message, the service showing remedy in a reindex result and its log and never to a search caller.
  • PR body: test block pinned to 065c98ff. Changeset, README and docs pages: untouched by the delta, as read in round 2.

接受的偏差 (unchanged)

范围外去向 (unchanged)

落地条款

  • Clause-② declared and the path limb hit: the contract record below is PASS at this head.
  • Tier H: no seat flips it ready, queues it or arms auto-merge before an authorized approval. The request for approval goes out once every check at this head is green or an expected skip.
  • The CI evidence for the live suites, on the terms set in round 2. The two steps this PR adds to Temporal Conformance have never run in CI: the job does not run on a pull request, and the relay lets a seat dispatch no ci.yml run. What stands in is one reading by the dev: the job's own image by digest (pgvector 0.8.7 on PostgreSQL 16), the step's exact command, 47 of 47. The approver can run ci.yml by workflow_dispatch on the branch before approving. In the merge queue the job is advisory: a red there does not eject the entry, it lands and shows on main. So the landing seat reads that run on this PR's queue entry, and a red in the two new steps is a main-red for this lane.
  • A head that moves past prose owes a fresh record.

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 065c98ff72750a8bc8f2247bed8f91a1bbb116e3
Local-runs: probe — three package suites and 2 ablations in a scratch worktree, to confirm the round-2 item and its pin; nothing was pushed, and the live PostgreSQL files could not be run here.
Scope: packages/spec/src/contracts/knowledge-adapter.ts, packages/spec/src/contracts/embedder.ts, packages/spec/src/api/error-code-ledger.zod.ts, .github/workflows/ci.yml + packages/services/service-knowledge/src/knowledge-service.ts, packages/services/service-knowledge/src/knowledge-index-fingerprint.ts, packages/services/service-knowledge/src/knowledge-tools.ts, packages/services/service-knowledge/src/testing.ts, packages/services/service-knowledge/src/index.ts, packages/plugins/knowledge-memory/src/index.ts, packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts, packages/plugins/knowledge-pgvector/src/plugin.ts
Security-touching: yes
Rule-change-verified: none

① Derived judgments

  • Rounds 1 and 2 stand: every member is in the ADR-0161 K8 table in its decided shape (items 6, 7 and 8 a, b, c), each with its reader and its suite cases, all optional, additive-safe for knowledge-ragflow and for cloud's adapter and embedder; K8 items 3 and 14 are returned by the store as main landed them. The delta adds no member, key, option or export.
  • The spec delta is TSDoc in knowledge-adapter.ts: the remedy convention moves from beginBuild to the interface, in the same words. True of the code.
  • The transient-descriptor sentence added in round 2 is now true of the store on every call that compares a fingerprint.

② Semver level

  • Unchanged: Clause-②: yes, Metadata-protocol: none, patch on five packages. No narrowing; nothing released moves.

③ Boundary flags

④ Design judgment

packages/spec/src/contracts/knowledge-adapter.ts

  • Round-2 nit closed: one home for the remedy sentence, read by an adapter author before any member.

packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts
S1 (should-fix): closed.

  • Pinned: the listing asks for the embedder before it compares.
  • Round-2 nit closed: the statement list never names the generation row alone.

packages/services/service-knowledge/src/knowledge-service.ts

  • Untouched by the delta. Its round-2 nit is closed by the new case beside it: the service's side of the caller boundary is pinned without a database.

packages/spec/src/contracts/embedder.ts, packages/spec/src/api/error-code-ledger.zod.ts, .github/workflows/ci.yml, packages/services/service-knowledge/src/knowledge-index-fingerprint.ts, packages/services/service-knowledge/src/knowledge-tools.ts, packages/services/service-knowledge/src/testing.ts, packages/services/service-knowledge/src/index.ts, packages/plugins/knowledge-memory/src/index.ts, packages/plugins/knowledge-pgvector/src/plugin.ts

  • Untouched by the delta; hold as in rounds 1 and 2.

No must-fix, no should-fix. The CI reading of the live steps is a landing clause, not a finding in the code.

Implemented-by: session_01JQwxbX5BF433x8ooJNQVRp
Reviewed-by: session_01JQwxbW5anP6GDaVi5LKi2U

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:cloud#1 · os-warren · session_01JQwxbW5anP6GDaVi5LKi2U

Hand-off for approval (Tier H, .github/workflows/ci.yml, and over the 3000-line size line): seat record ACCEPT and ## Contract review PASS are in comment 7174823480, both on head 065c98ff72750a8bc8f2247bed8f91a1bbb116e3. CI on that head: 63 success, 11 expected skips, 0 failed, 0 pending (one PR-body guards run was cancelled by a body edit; its re-run 139513358642 on the same head is success).

  • 要你做的:批准这个新功能——自建部署可以直接用自己的 PostgreSQL(装 pgvector 扩展)做知识库向量检索,换了嵌入模型或切分方式后旧索引会被明确拒绝并提示重建;新包默认不启用,撤回只需不注册该插件。有一处请你知情:本单在 CI 里新加的两个「真数据库」步骤从未在 CI 里跑过(PR 上不跑),目前的依据是开发者用 CI 同一镜像本机跑出的 47/47;想在批准前亲眼看到结果,可以在分支 claude/project-thread-vcp8s3 上手动运行一次 ci.yml。这个任务在合并队列里只是提示性的,红了也不会拦住合并,所以入队后席位会盯着那次运行,红了按主干变红处理。另有一个接口放置问题(searchWithRefusals 是否进正式接口)本单维持现状,会另行请你定夺。批准后席位负责落地。

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 25, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 25, 2026 22:53
@os-zhuang
os-zhuang enabled auto-merge November 25, 2026 22:53
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit 9981f27 Nov 25, 2026
80 of 81 checks passed
@os-zhuang
os-zhuang deleted the claude/project-thread-vcp8s3 branch November 25, 2026 23:25
os-warren pushed a commit that referenced this pull request Nov 26, 2026
knowledge-pgvector and the index fingerprint landed on main (#37337).
searchWithRefusals validates the scope first, filters the admitted sources
by the scope and then by groupBy, and planSearches carries each source's
terms beside its fingerprint: searchRound hands the adapter both `index` and
`scope`. SearchTarget declares the terms, and sourcesGroupableBy keeps the
type of what it filters. The suite, the stubs, knowledge-memory and the
protocol sample declare both the generation keys and `scope`.

Claude-Session: https://claude.ai/code/session_01JQwxbZmjM1KubX3ZAoJPPm
Co-authored-by: Claude <noreply@anthropic.com>
os-warren pushed a commit that referenced this pull request Nov 26, 2026
knowledge-pgvector landed first (#37337), so it implements the scope as
every in-tree adapter that runs the suite does (#37308 item 4). The terms are
a union in the same inner WHERE as the organization filter, before ranking:
a record term on source_record_id, a metadata term on the stored jsonb value
of its field (a string or number equal to an id as text, or a list with such
an element; anything else holds for nothing). Ids and field names go as
bound parameters. A scope with no term that has ids ranks nothing. The live
contract run declares implements.scope, so the suite's record-term,
metadata-term and service-level parent cases run against PostgreSQL.

Claude-Session: https://claude.ai/code/session_01JQwxbZmjM1KubX3ZAoJPPm
Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/cd dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

knowledge-pgvector: an open vector store on PostgreSQL — tables, exact search, listing, chunks

3 participants